let hename: string = "我是一个好学生！";
hename = "6666";
let number: number = hename.length;
let d = hename.substring(1, 2);
const q: string = "我是一个好学生！";
q = "6666";
let w: number = 22;
w = 123;
let booleans: boolean = false;
booleans = true;
let array: number[] = [1, 2, 3];
array[1];
array[4] = 100;
let list: Array<string> = ["q", "w", "e"];
let un: null = null;
let n: undefined = undefined;
function schole(): void {
	console.log("我是一个好学生！");
};
const _er: object = { "q": 12, "sw": "123", "qw": null };
const map: object = { "key1": 12, "key2": "123", "key3": undefined };
//数字加法
function add(x: number, y: number): number {
	return x + y;
}
add(1, 2);

//字符串拼接
function st(x: string, y: string): string {
	return x + y;
}
st("我叫", "佳愉乐！");
/*   st("sd", "sad", "sad");   报错  */

//可选参数
function sd(x: string, y?: string): string {
	return x + y;
}
sd("qw");

function sd1(x: string, y?: string, z?: string): string {
	return x + y;
}
sd1("hello");

function name1(x: string, y: string, z?: string | number | boolean): string {
	if (z) {
		return x + y + z;//英文名字
	}
	return x + y;//中文名字
}
name1("佳", "愉乐");
name1("佳", "愉乐", 23);
name1("佳", "愉乐", false);

function name2(x: string, ...bname: string[]) {   //剩余参数
	return x + " " + bname.join(" ");
}

function addnumber(x: string | number, y: string | number) {
	if (typeof x === "number" && typeof y === "number") {
		return x + y;
	} else {
		return x.toString() + y.toString();
	}
}
